#include <iostream>
#include <vector>

using namespace std;

class Worker {
   public:
    string name, address;
    long int salary{};

    virtual void printInfo() {
        cout << "name:" << name << ",address:" << address
             << ",salary:" << salary << endl;
    }

    Worker() = default;

    ~Worker() {
        name = "";
        address = "";
        salary = 0;
    }
};

class AWorker : public Worker {
   public:
    AWorker(string& i_name, string& i_address, long int i_salary) {
        name = i_name;
        address = i_address;
        salary = i_salary;
    }

    ~AWorker() {
        name = "";
        address = "";
        salary = 0;
    }
};

class BWorker : public Worker {
   public:
    long int totalNumbers, every;

    void getSalary() { salary = totalNumbers * every; }

    BWorker(string& i_name,
            string& i_address,
            long int i_totalNumbers,
            long int i_every) {
        name = i_name;
        address = i_address;
        totalNumbers = i_totalNumbers;
        every = i_every;
    }

    ~BWorker() {
        name = "";
        address = "";
        totalNumbers = 0;
        every = 0;
        salary = 0;
    }
};

class CWorker : public Worker {
   public:
    long int totalHours, every;

    void getSalary() { salary = totalHours * every; }

    CWorker(string& i_name,
            string& i_address,
            long int i_totalHours,
            long int i_every) {
        name = i_name;
        address = i_address;
        totalHours = i_totalHours;
        every = i_every;
    }

    ~CWorker() {
        name = "";
        address = "";
        totalHours = 0;
        every = 0;
        salary = 0;
    }
};

int main(int argc, char const* argv[]) {
    vector<Worker*> vec;
    vector<Worker*>::iterator iter;

    int count;
    string name, address;
    long int salary, totalNumbers, every, totalHours;

    cin >> count;

    for (int i = 0; i < count; ++i) {
        // 创建对象
        cin >> name >> address >> salary;
        auto* a_worker = new AWorker(name, address, salary);
        cin >> name >> address >> totalNumbers >> every;
        auto* b_worker = new BWorker(name, address, totalNumbers, every);
        cin >> name >> address >> totalHours >> every;
        auto* c_worker = new CWorker(name, address, totalHours, every);

        b_worker->getSalary();
        c_worker->getSalary();

        vec.emplace_back(a_worker);
        vec.emplace_back(b_worker);
        vec.emplace_back(c_worker);
    }

    for (iter = vec.begin(); iter != vec.end(); ++iter) {
        (*iter)->printInfo();
    }
    return 0;
}